home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2007 December / PCWKCD1207B.iso / Windows marzen / Maxthon 2.0.4 / mx_2.0.4.5799.exe / template / FeedView / feed.xsl < prev   
Extensible Markup Language  |  2007-09-05  |  15KB  |  457 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--
  3. Feed View XSLT Template v 1.0
  4. SiC 2007-03-02 11:26:39
  5. -->
  6. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  7.                                 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  8.                                 xmlns:rss09="http://my.netscape.com/rdf/simple/0.9/"
  9.                                 xmlns:rss1="http://purl.org/rss/1.0/"
  10.                                 xmlns:atom03="http://purl.org/atom/ns#"
  11.                                 xmlns:atom1="http://www.w3.org/2005/Atom"
  12.  
  13.                                 xmlns:dc="http://purl.org/dc/elements/1.1/" 
  14.                                 xmlns:dcterms="http://purl.org/dc/terms/"
  15.                                 xmlns:content="http://purl.org/rss/1.0/modules/content/"
  16.                                 xmlns:annotate="http://purl.org/rss/1.0/modules/annotate/"
  17.                                 xmlns:reqv="http://purl.org/rss/1.0/modules/richequiv/"
  18.                                 xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  19.                                 xmlns:image="http://purl.org/rss/1.0/modules/image/"
  20.                                 xmlns:l="http://purl.org/rss/1.0/modules/link"
  21.                                 xmlns:syn="http://purl.org/rss/1.0/modules/syndication/"
  22.                                 xmlns:admin="http://webns.net/mvcb/"
  23.                                 xmlns:cc="http://web.resource.org/cc/"
  24.  
  25.                                 exclude-result-prefixes="rdf dc atom03 atom1 dcterms rss1 rss09 content annotate admin image cc reqv slash syn l"
  26.  
  27.                                 version="1.0">
  28.                                 
  29.     <xsl:output
  30.         indent="yes" omit-xml-declaration="yes"
  31.         method="html" encoding="utf-8"
  32.         doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
  33.     />
  34.  
  35.     <xsl:preserve-space elements="*"/>
  36.  
  37.     <!-- //////////////////// Main ///////////////////////////////// -->
  38.     
  39.     <!-- ********* main ********* -->
  40.     <xsl:template match="/">
  41.         <xsl:apply-templates select="/rss"/>
  42.         <xsl:apply-templates select="/rdf:RDF"/>
  43.         <xsl:apply-templates select="/atom03:feed"/>
  44.         <xsl:apply-templates select="/atom1:feed"/>
  45.     </xsl:template>
  46.  
  47.  
  48.     <!-- sub : wrapper -->
  49.     <xsl:template name="outputWrapper">
  50.  
  51.         <xsl:param name="title"/>
  52.         <xsl:param name="link"/>
  53.         <xsl:param name="type"/>
  54.         <xsl:param name="items"/>
  55.  
  56.         <html xmlns="http://www.w3.org/1999/xhtml">
  57.  
  58.         <head>
  59.             <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  60.             <title><xsl:value-of select="$type"/> :: <xsl:value-of select="$title"/></title>
  61.             <link rel="stylesheet" href="/?$LOCALREL$???SECURITYID??/Template/_shared/css/base.css" type="text/css" />
  62.             <link rel="stylesheet" href="/?$LOCALREL$???SECURITYID??/Template/FeedView/feed.css" type="text/css" />
  63.             <script type="text/javascript" src="/?$LOCALREL$???SECURITYID??/Template/_shared/js/func.js"></script>
  64.             <script type="text/javascript" src="/?$LOCALREL$???SECURITYID??/Template/FeedView/feed.js"></script>
  65.         </head>
  66.  
  67.         <body>
  68.             <xsl:attribute name="onload">maxFeedView.rebuildContent(<xsl:value-of select="count($items)"/>)</xsl:attribute>
  69.  
  70.     <div class="contentWrapper">
  71.  
  72.         <div class="content">
  73.             <div class="innerContent">
  74.                 
  75.                 <div class="feed-note">
  76.                     <h3>
  77.                         <img src="/?$LOCALREL$???SECURITYID??/Template/FeedView/images/feed.png" alt=""/>
  78.                         <a href="{$link}" target="_blank"><xsl:value-of select="$title"/></a>
  79.                         <span class="feed-type">
  80.                               [<xsl:value-of select="$type"/>]
  81.                         </span>
  82.                     </h3>
  83.                     <p><script type="text/javascript">maxFeedView.writeLang("explain")</script></p>
  84.                     <p>
  85.                         <a href="javascript:;" onclick="maxFeedView.addFeed();"><script type="text/javascript">maxFeedView.writeLang("add_feed")</script></a>
  86.                     </p>
  87.                 </div>
  88.  
  89.                 <xsl:apply-templates select="$items">
  90.                     <xsl:with-param name="mode" select="'full'"/>
  91.                 </xsl:apply-templates>
  92.  
  93.             </div>
  94.         </div>
  95.  
  96.         <div class="sidebar">
  97.             <div class="innerSidebar">
  98.  
  99.                 <div class="sidebarBlock">
  100.                 <h5><script type="text/javascript">maxFeedView.writeLang("title_list")</script></h5>
  101.                 <div class="sidebarContent">
  102.                     <ul>
  103.                         <xsl:apply-templates select="$items">
  104.                             <xsl:with-param name="mode" select="'list'"/>
  105.                         </xsl:apply-templates>
  106.                     </ul>
  107.                 </div>
  108.                 </div>
  109.  
  110.             </div>
  111.         </div>
  112.  
  113.     </div>
  114.  
  115.         </body>
  116.  
  117.         </html>
  118.  
  119.     </xsl:template>
  120.  
  121.     
  122.     <!-- sub : title list -->
  123.     <xsl:template name="outputList">
  124.  
  125.         <xsl:param name="title"/>
  126.         <xsl:param name="link"/>
  127.         <xsl:param name="escape_title" select="1"/>
  128.  
  129.         <li>
  130.             <a href="#{generate-id($link)}" title="{$title}" id="nav_{position()}">
  131.                 <xsl:value-of select="position()"/>
  132.                 ┬╗
  133.                 <xsl:choose>
  134.                     <xsl:when test="$escape_title=1">
  135.                         <xsl:value-of select="$title"/>
  136.                     </xsl:when>
  137.                     <xsl:otherwise>
  138.                         <xsl:value-of select="$title" disable-output-escaping="yes" />
  139.                     </xsl:otherwise>
  140.                 </xsl:choose>
  141.             </a>
  142.         </li>
  143.  
  144.     </xsl:template>
  145.  
  146.  
  147.     <!-- sub : item blocks -->
  148.     <xsl:template name="outputItem">
  149.  
  150.         <xsl:param name="title"/>
  151.         <xsl:param name="link"/>
  152.         <xsl:param name="author"/>
  153.         <xsl:param name="date"/>
  154.         <xsl:param name="description" select="''"/>
  155.         <xsl:param name="escape_desc" select="1"/>
  156.         <xsl:param name="escape_title" select="1"/>
  157.  
  158.         <div class="contentBlock">
  159.         <div class="contentText">
  160.             <a name="{generate-id($link)}" />
  161.             <h4>
  162.                 <div class="go-top">
  163.                     <a href="javascript:window.scroll(0,0);">
  164.                         <img src="/?$LOCALREL$???SECURITYID??/Template/FeedView/images/go_top.png" alt=""/>
  165.                     </a>
  166.                 </div>
  167.                 <a href="{$link}" target="_blank">
  168.                     <xsl:attribute name="id">title_<xsl:value-of select="position()"/></xsl:attribute>
  169.                     <xsl:value-of select="position()"/>
  170.                     ┬╗
  171.                     <xsl:choose>
  172.                         <xsl:when test="$escape_title=1">
  173.                             <xsl:value-of select="$title"/>
  174.                         </xsl:when>
  175.                         <xsl:otherwise>
  176.                             <xsl:value-of select="$title" disable-output-escaping="yes" />
  177.                         </xsl:otherwise>
  178.                     </xsl:choose>
  179.                 </a>
  180.             </h4>
  181.             <p class="label">
  182.                 <xsl:value-of select="$date"/>
  183.                 <xsl:if test="$author!='' and $author!=''"> | </xsl:if>
  184.                 <xsl:value-of select="$author"/>
  185.             </p>
  186.             <div>
  187.                 <xsl:attribute name="id">content_<xsl:value-of select="position()"/></xsl:attribute>
  188.             </div>
  189.             <pre style="display:none">
  190.                 <xsl:attribute name="id">content_data_<xsl:value-of select="position()"/></xsl:attribute>
  191.                 <xsl:choose>
  192.                     <xsl:when test="$escape_desc=1">
  193.                         <xsl:value-of select="$description" />
  194.                     </xsl:when>
  195.                     <xsl:otherwise>
  196.                         <xsl:value-of select="$description" disable-output-escaping="yes" />
  197.                     </xsl:otherwise>
  198.                 </xsl:choose>
  199.             </pre>
  200.             <br style="clear:left" />
  201.         </div>
  202.         </div>
  203.  
  204.     </xsl:template>    
  205.     
  206.  
  207.     <!-- //////////////////// Helper Templates ///////////////////////////////// -->
  208.     
  209.     <!-- ********* RSS 2.0/0.92 ********* -->
  210.     <!-- sub : wrapper -->
  211.     <xsl:template match="/rss">
  212.  
  213.         <xsl:call-template name="outputWrapper">
  214.             <xsl:with-param name="type" select="concat('RSS ', /rss/@version)"/>
  215.             <xsl:with-param name="title" select="//channel/title"/>
  216.             <xsl:with-param name="link" select="//channel/link"/>
  217.             <xsl:with-param name="items" select="channel/item"/>
  218.         </xsl:call-template>
  219.  
  220.     </xsl:template>
  221.  
  222.     <!-- sub : item -->
  223.     <xsl:template match="channel/item">
  224.  
  225.         <xsl:param name="mode" select="'full'" />
  226.  
  227.         <xsl:choose>
  228.             <xsl:when test="$mode='list'">
  229.                 <xsl:call-template name="outputList">
  230.                     <xsl:with-param name="title" select="title"/>
  231.                     <xsl:with-param name="link" select="link"/>
  232.                 </xsl:call-template>
  233.             </xsl:when>
  234.             <xsl:otherwise>
  235.                 <xsl:call-template name="outputItem">
  236.                     <xsl:with-param name="title" select="title"/>
  237.                     <xsl:with-param name="link" select="link"/>
  238.                     <xsl:with-param name="description" select="description"/>
  239.                     <xsl:with-param name="author" select="author"/>
  240.                     <xsl:with-param name="date" select="pubDate"/>
  241.                 </xsl:call-template>
  242.             </xsl:otherwise>
  243.         </xsl:choose>
  244.  
  245.     </xsl:template>
  246.  
  247.  
  248.     <!-- ********* RSS 1.0 & 0.9 ********* -->
  249.     <!-- sub : wrapper -->
  250.     <xsl:template match="/rdf:RDF">
  251.  
  252.         <xsl:choose>
  253.             <xsl:when test="count(rss09:item)>0">
  254.                 <xsl:call-template name="outputWrapper">
  255.                     <xsl:with-param name="type" select="'RSS 0.9'"/>
  256.                     <xsl:with-param name="title" select="//rss09:channel/rss09:title"/>
  257.                     <xsl:with-param name="link" select="//rss09:channel/rss09:link"/>
  258.                     <xsl:with-param name="items" select="rss09:item"/>
  259.                 </xsl:call-template>
  260.             </xsl:when>
  261.             <xsl:otherwise>
  262.                 <xsl:call-template name="outputWrapper">
  263.                     <xsl:with-param name="type" select="'RSS 1.0'"/>
  264.                     <xsl:with-param name="title" select="//rss1:channel/rss1:title"/>
  265.                     <xsl:with-param name="link" select="//rss1:channel/rss1:link"/>
  266.                     <xsl:with-param name="items" select="rss1:item"/>
  267.                 </xsl:call-template>
  268.             </xsl:otherwise>
  269.         </xsl:choose>
  270.  
  271.     </xsl:template>
  272.  
  273.     <!-- sub : item 0.9 -->
  274.     <xsl:template match="rss09:item">
  275.  
  276.         <xsl:param name="mode" select="'full'" />
  277.  
  278.         <xsl:choose>
  279.             <xsl:when test="$mode='list'">
  280.                 <xsl:call-template name="outputList">
  281.                     <xsl:with-param name="title" select="rss09:title"/>
  282.                     <xsl:with-param name="link" select="rss09:link"/>
  283.                 </xsl:call-template>
  284.             </xsl:when>
  285.             <xsl:otherwise>
  286.                 <xsl:call-template name="outputItem">
  287.                     <xsl:with-param name="title" select="rss09:title"/>
  288.                     <xsl:with-param name="link" select="rss09:link"/>
  289.                     <xsl:with-param name="description" select="rss09:description"/>
  290.                 </xsl:call-template>
  291.             </xsl:otherwise>
  292.         </xsl:choose>
  293.  
  294.     </xsl:template>
  295.  
  296.     <!-- sub : item 1.0 -->
  297.     <xsl:template match="rss1:item">
  298.  
  299.         <xsl:param name="mode" select="'full'" />
  300.  
  301.         <xsl:choose>
  302.             <xsl:when test="$mode='list'">
  303.                 <xsl:call-template name="outputList">
  304.                     <xsl:with-param name="title" select="rss1:title"/>
  305.                     <xsl:with-param name="link" select="rss1:link"/>
  306.                 </xsl:call-template>
  307.             </xsl:when>
  308.             <xsl:otherwise>
  309.                 <xsl:call-template name="outputItem">
  310.                     <xsl:with-param name="title" select="rss1:title"/>
  311.                     <xsl:with-param name="link" select="rss1:link"/>
  312.                     <xsl:with-param name="description" select="rss1:description"/>
  313.                 </xsl:call-template>
  314.             </xsl:otherwise>
  315.         </xsl:choose>
  316.  
  317.     </xsl:template>
  318.  
  319.  
  320.     <!-- ********* Atom 0.3 ********* -->
  321.     <!-- sub : wrapper -->
  322.     <xsl:template match="/atom03:feed">
  323.  
  324.         <xsl:call-template name="outputWrapper">
  325.             <xsl:with-param name="type" select="'Atom 0.3'"/>
  326.             <xsl:with-param name="title" select="atom03:title"/>
  327.             <xsl:with-param name="link" select="atom03:link[@rel='alternate' and @type='text/html']/@href"/>
  328.             <xsl:with-param name="items" select="atom03:entry"/>
  329.         </xsl:call-template>
  330.  
  331.     </xsl:template>
  332.  
  333.     <!-- sub : item -->
  334.     <xsl:template match="atom03:entry">
  335.  
  336.         <xsl:param name="mode" select="'full'" />
  337.  
  338.         <xsl:variable name="desc">
  339.         <xsl:choose>
  340.             <xsl:when test="atom03:content[contains(@type,'html')]">
  341.                 <xsl:value-of select="atom03:content[contains(@type, 'html')]"/>
  342.             </xsl:when>
  343.             <xsl:otherwise>
  344.                 <xsl:value-of select="atom03:summary"/>
  345.             </xsl:otherwise>
  346.         </xsl:choose>
  347.         </xsl:variable>
  348.  
  349.         <xsl:choose>
  350.             <xsl:when test="$mode='list'">
  351.                 <xsl:call-template name="outputList">
  352.                     <xsl:with-param name="title" select="atom03:title"/>
  353.                     <xsl:with-param name="link" select="atom03:link[@rel='alternate' and @type='text/html']/@href"/>
  354.                 </xsl:call-template>
  355.             </xsl:when>
  356.             <xsl:otherwise>
  357.                 <xsl:call-template name="outputItem">
  358.                     <xsl:with-param name="title" select="atom03:title"/>
  359.                     <xsl:with-param name="link" select="atom03:link[@rel='alternate' and @type='text/html']/@href"/>
  360.                     <xsl:with-param name="description" select="$desc"/>
  361.                     <xsl:with-param name="author" select="atom03:author/atom03:name"/>
  362.                     <xsl:with-param name="date" select="atom03:modified"/>
  363.                 </xsl:call-template>
  364.             </xsl:otherwise>
  365.         </xsl:choose>
  366.  
  367.     </xsl:template>
  368.  
  369.  
  370.     <!-- ********* Atom 1.0 ********* -->
  371.     <!-- sub : wrapper -->
  372.     <xsl:template match="/atom1:feed">
  373.  
  374.         <xsl:call-template name="outputWrapper">
  375.             <xsl:with-param name="type" select="'Atom 1.0'"/>
  376.             <xsl:with-param name="title" select="atom1:title"/>
  377.             <xsl:with-param name="link" select="atom1:link[@rel='alternate' and @type='text/html']/@href"/>
  378.             <xsl:with-param name="items" select="atom1:entry"/>
  379.         </xsl:call-template>
  380.  
  381.     </xsl:template>
  382.  
  383.     <!-- sub : item -->
  384.     <xsl:template match="atom1:entry">
  385.         
  386.         <xsl:param name="mode" select="'full'"/>
  387.         
  388.         <!-- title -->
  389.         <xsl:variable name="title">
  390.         <xsl:choose>
  391.             <xsl:when test="atom1:title[@type='xhtml']">
  392.                 <xsl:value-of select="atom1:title[@type='xhtml']/div"/>
  393.             </xsl:when>
  394.             <xsl:when test="atom1:title[@type='html']">
  395.                 <xsl:value-of select="atom1:title[@type='html']"/>
  396.             </xsl:when>
  397.             <xsl:otherwise>
  398.                 <xsl:value-of select="atom1:title"/>
  399.             </xsl:otherwise>
  400.         </xsl:choose>
  401.         </xsl:variable>
  402.  
  403.         <xsl:variable name="escape_title">
  404.         <xsl:choose>
  405.             <xsl:when test="atom1:title[contains(@type,'html')]">
  406.                 <xsl:value-of select="0"/>
  407.             </xsl:when>
  408.             <xsl:otherwise>
  409.                 <xsl:value-of select="1"/>
  410.             </xsl:otherwise>
  411.         </xsl:choose>
  412.         </xsl:variable>
  413.  
  414.         <!-- description -->
  415.         <xsl:variable name="desc">
  416.         <xsl:choose>
  417.             <xsl:when test="atom1:content[@type='xhtml']">
  418.                 <xsl:value-of select="atom1:content[@type='xhtml']/div"/>
  419.             </xsl:when>
  420.             <xsl:when test="atom1:content[@type='html']">
  421.                 <xsl:value-of select="atom1:content[@type='html']"/>
  422.             </xsl:when>
  423.             <xsl:when test="atom1:summary[@type='xhtml']">
  424.                 <xsl:value-of select="atom1:summary[@type='xhtml']/div"/>
  425.             </xsl:when>
  426.             <xsl:when test="atom1:summary[@type='html']">
  427.                 <xsl:value-of select="atom1:summary[@type='html']"/>
  428.             </xsl:when>
  429.             <xsl:otherwise>
  430.                 <xsl:value-of select="atom1:summary"/>
  431.             </xsl:otherwise>
  432.         </xsl:choose>
  433.         </xsl:variable>
  434.         
  435.         <xsl:choose>
  436.             <xsl:when test="$mode='list'">
  437.                 <xsl:call-template name="outputList">
  438.                     <xsl:with-param name="title" select="atom1:title"/>
  439.                     <xsl:with-param name="escape_title" select="$escape_title"/>
  440.                     <xsl:with-param name="link" select="atom1:link[@rel='alternate' or @type='text/html']/@href"/>
  441.                 </xsl:call-template>
  442.             </xsl:when>
  443.             <xsl:otherwise>
  444.                 <xsl:call-template name="outputItem">
  445.                     <xsl:with-param name="title" select="$title"/>
  446.                     <xsl:with-param name="escape_title" select="$escape_title"/>
  447.                     <xsl:with-param name="link" select="atom1:link[@rel='alternate' or @type='text/html']/@href"/>
  448.                     <xsl:with-param name="description" select="$desc"/>
  449.                     <xsl:with-param name="author" select="atom1:author/atom1:name"/>
  450.                     <xsl:with-param name="date" select="atom1:updated"/>
  451.                 </xsl:call-template>
  452.             </xsl:otherwise>
  453.         </xsl:choose>
  454.  
  455.     </xsl:template>
  456.  
  457. </xsl:stylesheet>